package com.bndg.shu.shuyinyangshi.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.bndg.shu.shuyinyangshi.MyApp;

/**
 * Created by r on 17/3/22.
 */

public class PrefUtils {
    public static final String SHAREDPREF_NAME = "SHU_YYS";

    public static void putInt(String key, int value) {
        SharedPreferences pref = MyApp.mContext.getSharedPreferences(SHAREDPREF_NAME, Context.MODE_PRIVATE);
        pref.edit().putInt(key, value).apply();
    }

    public static void putString(String key, String value) {
        SharedPreferences pref = MyApp.mContext.getSharedPreferences(SHAREDPREF_NAME, Context.MODE_PRIVATE);
        pref.edit().putString(key, value).apply();
    }

    public static void putBoolean(String key, boolean value) {
        SharedPreferences pref = MyApp.mContext.getSharedPreferences(SHAREDPREF_NAME, Context.MODE_PRIVATE);
        pref.edit().putBoolean(key, value).apply();
    }

    public static void putFloat(String key, float value) {
        SharedPreferences pref = MyApp.mContext.getSharedPreferences(SHAREDPREF_NAME, Context.MODE_PRIVATE);
        pref.edit().putFloat(key, value).apply();
    }

    public static int getInt(String key, int defValue) {
        SharedPreferences pref = MyApp.mContext.getSharedPreferences(SHAREDPREF_NAME, Context.MODE_PRIVATE);
        return pref.getInt(key, defValue);
    }

    public static String getString(String key, String defValue) {
        SharedPreferences pref = MyApp.mContext.getSharedPreferences(SHAREDPREF_NAME, Context.MODE_PRIVATE);
        return pref.getString(key, defValue);
    }

    public static boolean getBoolean(String key, boolean defValue) {
        SharedPreferences pref = MyApp.mContext.getSharedPreferences(SHAREDPREF_NAME, Context.MODE_PRIVATE);
        return pref.getBoolean(key, defValue);
    }

    public static float getFloat(String key, float defValue) {
        SharedPreferences pref = MyApp.mContext.getSharedPreferences(SHAREDPREF_NAME, Context.MODE_PRIVATE);
        return pref.getFloat(key, defValue);
    }
}
